import Vue from 'vue'
import VueRouter, {RouteConfig} from 'vue-router'
import Layout from '@/layout/index.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [

    // 主页面
    {
        path: '/',
        name: 'home',
        component: Layout,
        meta:{
            isReturn: true,
        }
    },
    // 登录页面
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login/index.vue')
    },
    // 注册页面
    {
        path: '/sign',
        name: 'sign',
        component: () => import('@/views/register/index.vue'),
        redirect: '/sign/first',
        children: [
            {
                path: 'first',
                name: 'first',
                component: () => import('@/views/register/component/first.vue'),
            },
            {
                path: 'second',
                name: 'second',
                component: () => import('@/views/register/component/second.vue'),
            },
        ]
    },

    {
        path: '/student',
        name: 'studentIndex',
        meta:{
            login_required: true,
        },
        component: () => import('@/views/student/index.vue'),

    },
    {
        path: '/teacher',
        name: 'teacherIndex',
        meta:{
            login_required: true,
        },
        component: () => import('@/views/teacher/index.vue'),
    },
    {
        path: '/admin',
        name: 'adminIndex',
        meta:{
            login_required: true,
            isReturn: true,
        },
        component: () => import('@/views/admin/index.vue'),
    },
    // 个人信息管理
    {
        path: '/info',
        name: 'infoIndex',
        meta:{
            login_required: true,
        },
        component: () => import('@/views/common/personalData/index.vue'),
        redirect: '/info/personal',
        children:[
            {
                path: 'personal',
                name: 'personal',
                meta:{
                    login_required: true,
                },
                component: () => import('@/views/common/personalData/component/personal.vue'),
            },
            {
                path: 'college',
                name: 'college',
                meta:{
                    login_required: true,
                },
                component: () => import('@/views/common/personalData/component/college.vue'),
            },
            {
                path: 'password',
                name: 'password',
                meta:{
                    login_required: true,
                },
                component: () => import('@/views/common/personalData/component/password.vue'),
            },
            {
                path: 'safe',
                name: 'safe',
                meta:{
                    login_required: true,
                },
                component: () => import('@/views/common/personalData/component/safe.vue'),
            },
        ]
    },

    // 学生添加班级课程
    {
        path: '/classes',
        name: 'classes',
        component: () => import('@/views/common/add/addClass.vue'),
        meta:{
            login_required: true,
        },
    },

    // 班级课程页面
    {
        path: '/course',
        name: 'course',
        component: () => import('@/views/common/course/index.vue'),
        meta:{
            login_required: true,
        },
    },

    // 班级课程页面
    {
        path: '/tea//homework',
        name: 'teaHomework',
        component: () => import('@/views/teacher/addHomework.vue'),
        meta:{
            login_required: true,
        },
    },

    // 老师作业查看页面
    {
        path: '/homework/tea',
        name: 'teaHomeworkView',
        component: () => import('@/views/common/homework/teaIndex.vue'),
        meta:{
            login_required: true,
        },
    },
    // 学生作业详情页面
    {
        path: '/homework/stu',
        name: 'stuHomeworkView',
        component: () => import('@/views/common/homework/stuIndex.vue'),
        meta:{
            login_required: true,
            if_write: false,
        },
    },
    // 学生写作业页面
    {
        path: '/homework/stu/write',
        name: 'stuHomeworkWrite',
        component: () => import('@/views/student/homework.vue'),
        meta:{
            login_required: true,
            if_write: true,
        },
    },

]

const router = new VueRouter({
    routes
})

export default router
